<script>
import { mapState } from 'vuex'
import { config, formConfig, column } from './formConfig.js'
import SearchManage from '@/components/basic/SearchManage.vue'

export default {
    extends: SearchManage,
    data() {
        return {
            table_title: '固定阈值',
            url: 'sthred',
            queryForm: {
                page: 1,
                size: 20,
                device_name: null,
                sensor_name: null,
                eigenvalue: null,
                scope_id: null,
                scope_id_list: [],
            },
            queryFormC: {
                page: 1,
                size: 20,
                device_name: null,
                sensor_name: null,
                eigenvalue: null,
                scope_id: null,
                scope_id_list: [],
            },
        }
    },
    computed: {
        ...mapState('backstage', ['backstageData', 'eigenvalueTags']),
        tags() {
            if (this.pagination.total !== undefined) {
                return [{ title: '总数', num: this.pagination.total }, null, null, null]
            } else return []
        },
    },
    created() {
        this.searchBtn()
        formConfig[0].options = this.backstageData
        formConfig[3].options = this.eigenvalueTags.map((item) => Object.assign(item, { label: item.name, value: item.nickname }))
        this.formConfig = formConfig
        this.dialog.config = config
        column[column.length - 1].buttons = [
            {
                text: '编辑',
                click: (val) => this.handleEdit(val),
                icon: 'el-icon-edit',
            },
        ]
        column[column.length - 1].if = this.operate
        this.tableColumn = column
    },
}
</script>
